//
//  MCWithdrawPayCardTableViewCell.m
//  TLYL
//
//  Created by MC on 2017/7/10.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCWithdrawPayCardTableViewCell.h"

@interface MCWithdrawPayCardTableViewCell()

@property (nonatomic,strong)UIImageView * imgV_logo;
@property (nonatomic,strong)UILabel * lab_card;
@property (nonatomic,strong)UIView * view_line;
/*
 * ￥
 */
@property (nonatomic,strong)UILabel * lab_L;
@property (nonatomic,strong)UITextField * textField;
@property (nonatomic,strong)UIButton * btn_ALL;

@property (nonatomic,strong)UIImageView * imgV_arrow;

@end

@implementation MCWithdrawPayCardTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    self.backgroundColor=RGB(242, 242, 242);
    
    
    /*
     * logo
     */
    _imgV_logo=[[UIImageView alloc]init];
    [self addSubview:_imgV_logo];
    _imgV_logo.backgroundColor=RGB(80, 141, 207);
    _imgV_logo.clipsToBounds=YES;
    _imgV_logo.layer.cornerRadius=15;
    
    
    /*
     * 银行卡
     */
    _lab_card =[[UILabel alloc]initWithFrame:CGRectZero];
    _lab_card.textColor=RGB(40, 40, 40);
    _lab_card.font=[UIFont systemFontOfSize:15];
    _lab_card.text =@"加载中";
    _lab_card.textAlignment=NSTextAlignmentLeft;
    [self  addSubview:_lab_card];
    
    /*
     * 箭头
     */
    _imgV_arrow=[[UIImageView alloc]init];
    [self addSubview:_imgV_arrow];
    _imgV_arrow.alpha=0.7;
    _imgV_arrow.image=[UIImage imageNamed:@"MC_right_arrow"];
    
    
    /*
     * 画线
     */
    _view_line=[[UIView alloc]init];
    _view_line.backgroundColor=[UIColor grayColor];
    [self addSubview:_view_line];
    

    /*
     * ￥
     */
    _lab_L =[[UILabel alloc]initWithFrame:CGRectZero];
    _lab_L.textColor=RGB(0, 0, 0);
    _lab_L.font=[UIFont systemFontOfSize:30];
    _lab_L.text =@"￥";
    _lab_L.textAlignment=NSTextAlignmentLeft;
    [self  addSubview:_lab_L];

    _textField=[[UITextField alloc] init];
    [self setTextField:_textField WithPlaceholder:@"单笔提款金额范围：10-5000元" and:UIKeyboardTypeNumberPad];
    [_textField setValue:[UIFont systemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];

    

    _btn_ALL=[[UIButton alloc]init];
    [self addSubview:_btn_ALL];
    [_btn_ALL setTitle:@"全部转出" forState:UIControlStateNormal];
    [_btn_ALL.titleLabel setTextColor:RGB(60, 130, 207)];
    [_btn_ALL setTitleColor:RGB(60, 130, 207) forState:UIControlStateNormal];
    [_btn_ALL addTarget:self action:@selector(withdraw_AllMoney) forControlEvents:UIControlEventTouchUpInside];
    
    
  
    
    [self relayOutConstraints];
}
-(void)setTextField:(UITextField*)textField WithPlaceholder:(NSString *)placeholder and:(UIKeyboardType)type{
    textField.placeholder=placeholder;
    textField.borderStyle = UITextBorderStyleNone;
    textField.backgroundColor=[UIColor clearColor];
    textField.font = [UIFont systemFontOfSize:13];
    textField.textColor = RGB(100, 100, 100);
    textField.textAlignment = NSTextAlignmentLeft;
    textField.returnKeyType = UIReturnKeyDone;
    textField.keyboardType = type;
    [textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:(UIControlEventEditingChanged)];
    [self addSubview:textField];
    
}
-(void)textFieldDidChange:(UITextField *)textfield{
    
    if (_textField.text.length>4) {
        _textField.text =  [_textField.text substringToIndex:5];
    }
}
#pragma mark-全部提现
-(void)withdraw_AllMoney{
    _textField.text=@"3425.65";
}
-(void)relayOutConstraints{
    
    [_imgV_logo mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(self.mas_top).offset(5);
        make.width.equalTo(@(30));
        make.height.equalTo(@(30));
        make.left.equalTo(self.mas_left).offset(5);
        
    }];
    
    [_lab_card mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_imgV_logo.mas_centerY);
        make.left.equalTo(_imgV_logo.mas_right).offset(5);
        make.right.equalTo(self.mas_right).offset(-50);
    }];
    
    
    [_imgV_arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_imgV_logo.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-10);
        make.height.mas_equalTo(26*0.6);
        make.width.mas_equalTo(16*0.6);
    }];
    
    [_view_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(40);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(0.5);
    }];
    
    
    [_lab_L mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_view_line.mas_bottom);
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.mas_left).offset(10);
        make.width.mas_equalTo(30);
    }];
    
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(_lab_L).offset(0);
        make.left.equalTo(_lab_L.mas_right).offset(0);
        make.right.equalTo(self.mas_right).offset(-100);
    }];
    
    [_btn_ALL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_view_line.mas_bottom);
        make.bottom.equalTo(self.mas_bottom);
        make.right.equalTo(self.mas_right).offset(-10);

    }];

    
}

-(void)setDataSource:(id)dataSource{
    
    _dataSource=dataSource;
    _lab_card.text =@"中国工商银行（6508）";
    
}

+(CGFloat)computeHeight:(id)info{
    
    return 100;
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
